package servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LoginServlet
 */
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LoginServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//data from service
		User u=new User();
		u.setId(2);u.setUname("JohnYu");
		User u1=new User();
		u1.setId(3);u1.setUname("TomLi");
		request.getSession().setAttribute("u", u1);
		request.setAttribute("u", u);
		List<User> us=new ArrayList<User>();
		for(int i=0;i<10;i++){
			User uu=new User();
			uu.setId(i);
			uu.setUname("John"+i);
			us.add(uu);
		}
		
		request.setAttribute("us", us);
		
		
		
		request.getRequestDispatcher("show.jsp").forward(request, response);
	}

}






